#define _CRT_SECURE_NO_WARNINGS 1


#include<vector>
#include<iostream>

using namespace std;

int findPoisonedDuration(vector<int>& timeSeries, int duration)
{
	int size = timeSeries.size(), sum = 0;
	for (int i = 0; i < size; i++)
	{
		if (i + 1 < size && timeSeries[i] + duration - 1 >= timeSeries[i + 1])
		{
			sum += timeSeries[i + 1] - timeSeries[i];
		}
		else
		{
			sum += duration;
		}
	}
	return sum;
}

int main()
{
	vector<int> v = { 1,4 };
	cout << findPoisonedDuration(v, 2) << endl;

	return 0;
}